
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Square.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Square_calculateArea)
{
    TEST(Input length: 2.345, the area of square should be :2.34 * 2.34 = 5.4756,approximately equals 5.48)
    {
        Square square(2.345);
        ASSERT_EQ(5.48, square.calculateArea());
    }

    TEST(Input length: 75.0013, the area of square should be 75 * 75 = 5625)
    {
        Square square(75.0013);
        ASSERT_EQ(5625, square.calculateArea());
    }
    TEST(the length can be set, the area of square  should be: (20 * 20) = 400)
    {
        Square square(2.345);
        square.setLength(20);
        ASSERT_EQ(400, square.calculateArea());
    }

    TEST(the input length is invalid, the area of square  should be: 2.34 *2.34 = 5.48)
    {
        Square square(2.345);
        square.setLength(80);
        ASSERT_EQ(5.48, square.calculateArea());
    }

    TEST(Input length: 1000 the area of square should be 0)
    {
        Square square(1000);
        ASSERT_EQ(0, square.calculateArea());
    }

    TEST(Input length: 0, the area of square should be 0)
    {
        Square square(0);
        ASSERT_EQ(0, square.calculateArea());
    } 

    TEST(Input length: -5, the area of square should be 0)
    {
        Square square(-5);
        ASSERT_EQ(0, square.calculateArea());
    } 
};

FIXTURE(Square_calculatePerimeter)
{ 
    TEST(Input length: 2.345, the primeter of square should be: 2.34 * 4 = 9.36)
    {
        Square square(2.345);
        ASSERT_EQ(9.36, square.calculatePerimeter());
    }

    TEST(Input length: 75.0013, the primeter of square should be 75 * 4 = 300)
    {
        Square square(75.0013);
        ASSERT_EQ(300, square.calculatePerimeter());
    }

 
    TEST(the length can be set, the area of square  should be: (20 * 4) = 80)
    {
        Square square(2.345);
        square.setLength(20);
        ASSERT_EQ(80, square.calculatePerimeter());
    }

    TEST(the input length is invlid, the area of square  should be: 2.34 * 4 = 9.36)
    {
        Square square(2.345);
        square.setLength(80);
        ASSERT_EQ(9.36, square.calculatePerimeter());
    }

    TEST(Input length: 1000, the primeter of square should be 0)
    {
        Square square(1000);
        ASSERT_EQ(0, square.calculatePerimeter());
    }

    TEST(Input length: 0,  the primeter of square should be 0)
    {
        Square square(0);
        ASSERT_EQ(0, square.calculatePerimeter());
    } 

    TEST(Input length: -5,  the primeter of square should be 0)
    {
        Square square(-5);
        ASSERT_EQ(0, square.calculatePerimeter());
    }   
};


